﻿using System;
using System.IO;

namespace _017_流之调用Seek方法重新设置流的当前位置
{
    class Program
    {
        static void Main(string[] args)
        {
            using (MemoryStream 创建起步=new MemoryStream())
            {
                Console.WriteLine("写入流的字节：\n");
                for (byte i = 0; i < 8; i++)
                {
                    创建起步.WriteByte(i);
                    Console.Write(" 0x{0:x2}", i);
                }
                Console.WriteLine("\n");

                //改变流的当前位置
                创建起步.Seek(-3, SeekOrigin.End);

                Console.WriteLine("最后3个字节为：");
                int 结尾;
                while ((结尾=创建起步.ReadByte())>-1)
                {

                    Console.Write(" 0x{0:x2}", 结尾);
                }

            }

        }
    }
}
